package model

import (
	"context"

	"github.com/Masterminds/squirrel"
	"github.com/zeromicro/go-zero/core/stores/sqlx"
)

var _ AwCityInfosModel = (*customAwCityInfosModel)(nil)

type (
	// AwCityInfosModel is an interface to be customized, add more methods here,
	// and implement the added methods in customAwCityInfosModel.
	AwCityInfosModel interface {
		awCityInfosModel
		withSession(session sqlx.Session) AwCityInfosModel
		GetAll(ctx context.Context,session sqlx.Session)([]*AwCityInfos,error)
	}

	customAwCityInfosModel struct {
		*defaultAwCityInfosModel
	}
)

// NewAwCityInfosModel returns a model for the database table.
func NewAwCityInfosModel(conn sqlx.SqlConn) AwCityInfosModel {
	return &customAwCityInfosModel{
		defaultAwCityInfosModel: newAwCityInfosModel(conn),
	}
}

func (m *customAwCityInfosModel) withSession(session sqlx.Session) AwCityInfosModel {
	return NewAwCityInfosModel(sqlx.NewSqlConnFromSession(session))
}

func (m *customAwCityInfosModel)GetAll(ctx context.Context,session sqlx.Session)([]*AwCityInfos,error){
	query,args,err := squirrel.Select("*").From(m.table).ToSql()
	if err != nil {
		return nil,err
	}
	var citys []*AwCityInfos
	if session != nil {
		err = session.QueryRowsPartialCtx(ctx,&citys,query,args...)
	}else{
		err = m.conn.QueryRowsPartialCtx(ctx,&citys,query,args...)
	}
	return citys,err
}
